﻿using System;
using System.Web;
using System.Net;

using OctoOS;
using OctoOS.Services;
using OctoOS.UI;


public partial class samples__post : OOSPage
{
	internal class QueryString
	{
		[QueryStringMember()]
		internal long Thread = 0;

		[QueryStringMember()]
		internal long Post = 0;
	}

	protected void Page_Init(object sender, EventArgs e)
	{
		QueryString queryString = EnableQueryString<QueryString>();

		var response = OctoServices.Process(OOSRequest.Current,
			new Post_GetThreadTreeCommentPageIndex(queryString.Thread,
				queryString.Post, TreeThread.DefaultMinimumPageSize,
				TreeThread.DefaultOptimumPageSize)
				).CastOrHttpException<Post_GetCommentPageIndex_Response>();

		int pageIndex = response.PageIndex > 0 ? response.PageIndex + 1 : response.PageIndex;

		Response.Redirect(Urls.GetArticleDiscussion(queryString.Thread,
			response.ThreadTitle, pageIndex, queryString.Post));
	}
}